<?php

/**
 * @version		$Id: hello.php 15 2009-11-02 18:37:15Z chdemko $
 * @package		Joomla16.Tutorials
 * @subpackage	Components
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @author		Christophe Demko
 * @link		http://joomlacode.org/gf/project/helloworld_1_6/
 * @license		License GNU General Public License version 2 or later
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// add style
$doc = JFactory::getDocument();
$doc->addStyleSheet( 'components/com_bg/public/css/custom.css' );

// load BGController default
JLoader::register('BGController', JPATH_COMPONENT.DS.'controllers'.DS.'controller.php');

// get and set default controller, task
$controller = JRequest::getWord('view', 'user');
$task = JRequest::getWord('task', 'display');

// if File controller exist to display, else redirect index.php
jimport('joomla.filesystem.file');
if (JFile::exists(JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'))
{
    // intinial new object controller, excute method task
    require_once (JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
    $classname = 'BGController'.$controller;
    $controller = new $classname();
    $controller->execute($task);
    $controller->redirect();
}else{
    header('location:index.php');
}